/*
 * @Author: dailuyu
 * @Date: 2021-08-17 21:02:39
 * @Email: dly@hyrctec.com
 * @LastEditors: dailuyu
 * @LastEditTime: 2021-08-17 23:17:44
 * @Company: hyrc
 * @FilePath: \TaskErrorManageApi\database\Dao\ProjectManage\projectManage_dao.js
 * @Description:
 */
let { pool } = require("../../DBConfig.js")
let { AddProject, DeleteProject, QueryProject,GetProject,EditProject } = require('./projectMange_sql.js')
module.exports = {
  add: function (project, callback) { // project表中增加project操作
    let sqlparam = [
      project.Id ? project.Id : "",
      project.FId ? project.FId : "",
      project.Name ? project.Name : "",
      project.Remark ? project.Remark : "",
      project.UserId ? project.UserId : "",
      project.CreateDate ? project.CreateDate : "",
      project.IsUse ? project.IsUse : "",
      project.IsDelete ? project.IsDelete : "",
    ]
    console.log("sqlparam")
    console.log(sqlparam)
    pool.query(AddProject, sqlparam, function (error, result) {
      if (error) throw error
      callback(result)
    })
  },
  deleted: function (params, callback) { // users表中删除指定user操作
    let { id } = params
    let sqlparam = [id]
    pool.query(DeleteProject, sqlparam, function (error, result) {
      if (error) throw error
      callback(result)
    })
  },
  query: function (params, callback) { // users表中查询指定user操作
    let { id } = params
    let sqlparam = [id]
    pool.query(QueryProject, sqlparam, function (error, result) {
      if (error) throw error
      callback(result[0])
    })
  },
  get1: function (callback) { // users表中查询指定user操作

    pool.query(GetProject, function (error, result) {
      if (error) throw error
      callback(result)
    })
  },
  edit: function (project, callback) { // project表中修改project操作
    let sqlparam = [
      project.Name ? project.Name : "",
      project.Remark ? project.Remark : "",
      project.IsUse ? project.IsUse : "",
      project.IsDelete ? project.IsDelete : "",
      project.Id ? project.Id : "",
    ]
    pool.query(EditProject, sqlparam,function (error, result) {
      if (error) throw error
      callback(result)
    })
  },
}